package com.haisen.controller;


import com.haisen.core.utils.PageResultSet;
import com.haisen.core.utils.Result;
import com.haisen.dataobject.entity.UserWeixin;
import com.haisen.dataobject.query.UserWeixinQuery;
import com.haisen.service.UserWeixinService;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/userweixin")
@Slf4j
public class UserWeixinController {


    @Autowired
    private UserWeixinService userWeixinService;

    @RequiresPermissions("userweixin:view")
    @GetMapping

    public String page(Model model){
        setCommonDate(model);
        return "customer/userweixin";
    }

    @ResponseBody
    @RequestMapping("/list")
    @RequiresPermissions("userweixin:view")
    public PageResultSet<UserWeixin> list(UserWeixinQuery userWeixinQuery){
     return userWeixinService.findByPage(userWeixinQuery);
    }

    @ResponseBody
    @PostMapping("/create")
    @RequiresPermissions("userweixin:create")
    public Result create(@Validated UserWeixin userWeixin){
        userWeixinService.create(userWeixin);
        return Result.success();
    }

   @ResponseBody
   @PostMapping("/update")
   @RequiresPermissions("userweixin:update")
   public Result update(@Validated UserWeixin userWeixin){
        userWeixinService.update(userWeixin);
        return Result.success();
   }

   @ResponseBody
   @PostMapping("/delete")
   @RequiresPermissions("userweixin:delete")
   public Result delete(@RequestParam("id") Long[] ids ){
       userWeixinService.delete(ids);
       return Result.success();
   }
    @ResponseBody
    @RequiresPermissions("userweixin:import")
    @PostMapping("/import")
    public Result importExcel(@RequestParam("importpathfile") String pathFile) {
        userWeixinService.importExcel2DataBase(pathFile);
        return Result.success();
    }


    private void setCommonDate(Model model) {

    }

}
